<template>
    <div class="wrapper">
      <el-page-header @back="goBack" content="新闻详情"></el-page-header>
      <h2>{{newsDetail.theme}}</h2>
      <el-divider></el-divider>
      <div class="time_views">
        <span>发布时间：{{newsDetail.createTime ? newsDetail.createTime.substring(0,16) : ''}}</span>
        <span style="margin-left: 30px">浏览量：{{newsDetail.views}}</span>
      </div>
      <div class="details ql-editor" v-html="newsDetail.details">

      </div>
      <el-divider class="bottom_line"></el-divider>
    </div>
</template>

<script>
    import 'quill/dist/quill.core.css';
    import 'quill/dist/quill.snow.css';
    import 'quill/dist/quill.bubble.css';

    export default {
        name: "NewsDetails",
        data(){
            return{
                newsDetail: {}
            }
        },
        methods: {
            loadNewsDetail(){
                const newsId=this.$route.query.newsId;
                const params={newsId: newsId};
                this.getRequest('/getNewsDetail', params).then(resp=>{
                    if(resp){
                        this.newsDetail=resp;
                    }else{
                        console.log("新闻详情页获取失败");
                    }
                })
            },
            goBack(){
                this.$router.back();
            }
        },
        mounted() {
            this.loadNewsDetail();
        }
    }
</script>

<style scoped>
  .wrapper{
    padding-left: 5%;
  }
  h2{
    text-align: center;
    margin-top: 20px;
  }
  .el-divider{
    margin-bottom: 5px;
  }
  .time_views{
    font-size: small;
  }
  .details{
    margin-top: 30px;
    font-size: large;
    font-family: 华光仿宋_CNKI;
    line-height: 2em;
    min-height: 500px;
    text-indent: 2em;   /* 段落缩进2格 */
  }
  .bottom_line{
    margin-top: 8px;
  }
</style>
